package com.woniuxy.carlife.carlifeuserweb.util;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.util.Date;

/**
 * @author zjq
 * @ClassName:PoMetaObjectHandler
 * @Description:自动填充时间
 * @date 2021/4/9 21:57
 **/

@Component
@Slf4j
public class PoMetaObjectHandler implements MetaObjectHandler {
    //处理新增
    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("开始insert填充......");
        this.setFieldValByName("gmtCreate",new Date(),metaObject);
        this.setFieldValByName("gmtModified",new Date(),metaObject);
    }

    //处理修改
    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("开始update填充......");
        this.setFieldValByName("gmtModified",new Date(),metaObject);
    }
}
